<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex forgotPassword_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between forgotPassword_fd0_0'>
					<view class='flex flex-wrap align-center forgotPassword_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  forgotPassword_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex align-center justify-end forgotPassword_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---logoflex布局开始-->
			<view
				class="flex flex-direction flex-wrap align-center justify-center benben-flex-layout forgotPassword_flex_1">
				<image class='forgotPassword_fd1_0' mode="aspectFill" :src='STATIC_URL+"logo1.png"'></image>
			</view>

			<!---logoflex布局结束-->
			<!---登录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout forgotPassword_flex_2">
				<view class='flex flex-wrap align-center forgotPassword_fd2_0'>
					<image class='forgotPassword_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"7.png"'></image>
					<benben-input class='flex-sub forgotPassword_fd2_0_c1' type="number" :placeholder="`请输入手机号`"
						confirm-type="done" :maxlength="11"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="account" />
				</view>
				<view class='flex flex-wrap align-center forgotPassword_fd2_0'>
					<image class='forgotPassword_fd2_1_c0' mode="aspectFit" :src='STATIC_URL+"12.png"'></image>
					<benben-input class='flex-sub forgotPassword_fd2_1_c1' type="number" :placeholder="`请输入验证码`"
						confirm-type="done" :maxlength="4"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="code" />
					<benben-send-verification-code key='1676949350494' ref="vCode1676949350494"
						class=' forgotPassword_fd2_1_c2' after-text='后重新获取' before-text='获取验证码' type='2'
						:phone="account"></benben-send-verification-code>
				</view>
				<view class='flex flex-wrap align-center forgotPassword_fd2_0'>
					<image class='forgotPassword_fd2_1_c0' mode="aspectFit" :src='STATIC_URL+"8.png"'></image>
					<benben-flex-password-diy v-model="password"
						class-name="flex align-center flex-sub flex forgotPassword_fd2_2_c1"
						:placeholder="'请输入密码(6~12位字母+数字)'" :maxlength="12" :default-type='true'
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx">
						<template #show>
							<text class='fu-iconfont2  forgotPassword_fd2_2_c1_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  forgotPassword_fd2_2_c1_icon1' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
				<view class='flex flex-wrap align-center forgotPassword_fd2_0'>
					<image class='forgotPassword_fd2_1_c0' mode="aspectFit" :src='STATIC_URL+"8.png"'></image>
					<benben-flex-password-diy v-model="againPassword"
						class-name="flex align-center flex-sub flex  forgotPassword_fd2_2_c1"
						:placeholder="'请输入确认密码(6~12位字母+数字)'" :maxlength="12" :default-type='true'
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx">
						<template #show>
							<text class='fu-iconfont2  forgotPassword_fd2_2_c1_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  forgotPassword_fd2_2_c1_icon1' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
				<button class='forgotPassword_fd2_4' @tap.stop="forgotPasswordFunc()">确定</button>
			</view>

			<!---登录flex布局结束-->


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"account": "",
				"code": "",
				"password": "",
				"againPassword": "",
				"type": "forgot"
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				type,
				account
			} = options
			if (type !== undefined) this.type = type
			if (account !== undefined) this.account = account
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//忘记密码
			async forgotPasswordFunc() {
				if (!validate(this.account, 'require')) {
					this.$message.info('请输入手机号');
					return false;
				}
				if (!validate(this.account, 'phone')) {
					this.$message.info('请输入正确的手机号');
					return false;
				}
				if (!validate(this.code, 'require')) {
					this.$message.info('请输入验证码');
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info('请输入正确的验证码');
					return false;
				}
				if (!validate(this.password, 'require')) {
					this.$message.info('请输入密码(6~12位字母+数字)');
					return false;
				}
				if (!validate(this.password, 'password')) {
					this.$message.info('请输入正确密码(6~12位字母+数字)');
					return false;
				}
				if (!validate(this.againPassword, 'require')) {
					this.$message.info('请输入确认密码(6~12位字母+数字)');
					return false;
				}
				if (!validate(this.againPassword, 'password')) {
					this.$message.info('请输入正确确认密码(6~12位字母+数字)');
					return false;
				}
				if (!(this.againPassword == this.password)) {
					this.$message.info('新密码与确认密码不一致');
					return false;
				}
				//请求方法
				//数据验证
				let apiUrl = this.type == 'forgot' ? global.apiUrls.post5caeeba9866aa : global.apiUrls
					.post658241f239298
				let data5caeeba9866aa = await this.$api.dbPost(apiUrl, {
					password: this.password,
					againPassword: this.againPassword,
					account: this.account,
					code: this.code,
					type: '2',
					account_type: 'mobile',
					user_type: '3'
				});
				if (!data5caeeba9866aa) return
				if (data5caeeba9866aa.data.code != 1) {
					this.$message.info(data5caeeba9866aa.data.msg);
					return
				}
				this.$message.info(data5caeeba9866aa.data.msg)
				this.$urouter.redirectTo(`/pages/tabBar/logon/logon`);
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto;
	}

	.forgotPassword_flex_0 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
	}

	.forgotPassword_fd0_0_c0_c0 {
		color: #333;
		font-size: 32rpx;
	}

	.forgotPassword_fd0_0_c0 {
		width: 200rpx;
		height: 88rpx;
	}

	.forgotPassword_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.forgotPassword_flex_1 {
		padding: 22rpx 0rpx 104rpx 0rpx;
	}

	.forgotPassword_fd1_0 {
		width: 505rpx;
		height: 150rpx;
	}

	.forgotPassword_flex_2 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.forgotPassword_fd2_4 {
		background: #E31D1A;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		height: 80rpx;
		line-height: 80rpx;
		font-weight: 500;
		width: 638rpx;
		margin: 120rpx 24rpx 0rpx 24rpx;
	}

	.forgotPassword_fd2_2_c1_icon1 {
		text-align: center;
		font-size: 34rpx;
	}

	::v-deep .forgotPassword_fd2_2_c1 {
		font-size: 32rpx;
		color: #333;
		font-weight: 400;
		width: 615rpx;
	}

	.forgotPassword_fd2_1_c2 {
		line-height: 40rpx;
		font-size: 28rpx;
		color: rgba(227, 29, 26, 1);
		font-weight: 400;
	}

	.forgotPassword_fd2_1_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.forgotPassword_fd2_1_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 28rpx 0rpx 0rpx;
	}

	.forgotPassword_fd2_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.forgotPassword_fd2_0_c0 {
		width: 34rpx;
		height: 34rpx;
		margin: 0rpx 28rpx 0rpx 0rpx;
	}

	.forgotPassword_fd2_0 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 40rpx 0rpx;
	}
</style>